﻿using BlazorApp3.Client.Application.Services;

namespace BlazorApp3.Client.Application.Features.Counter.Queries.GetCurrentCounter;

internal class GetCurrentCounterQueryHandler : IRequestHandler<GetCurrentCounterQuery, int>
{
    private readonly ICounterRepository _counterRepository;

    public GetCurrentCounterQueryHandler(ICounterRepository counterRepo)
    {
        _counterRepository = counterRepo;
    }

    public async Task<int> Handle(GetCurrentCounterQuery request, CancellationToken cancellationToken)
    {
        var currentCount = await _counterRepository.GetCurrentCounter();
        return currentCount;
    }
}